import { Room } from '../../api/Room';

export class Card {
	constructor(readonly cardId: string) {}
	// 卡牌卡池
	pool: string = '';
	// 卡牌标签
	tags: string[] = [];

	// 介绍相关

	// 卡牌类型
	type(room: Room, user: string): string {
		return '基础卡';
	}

	// 卡牌目标
	target(room: Room, user: string): string {
		return 'this';
	}

	// 卡牌背景
	background(room: Room, user: string): string {
		return 'img/cards/default.png';
	}

	// 卡牌名称
	title(room: Room, user: string): string {
		return '未命名卡牌';
	}

	// 卡牌简介
	desc(room: Room, user: string): string {
		return '';
	}

	// 卡牌花费 (铜钱)
	costPoint(room: Room, user: string): number {
		return 1;
	}

	// 卡牌花费 (铜钱)
	costMoney(room: Room, user: string): number {
		return 25;
	}

	// 效果相关

	/**
	 * 回合开始时触发
	 * @param room 房间
	 * @param user 使用者
	 */
	turnStart(room: Room, user: string): void {}
	/**
	 * 回合结束时触发
	 * @param room 房间
	 * @param user 使用者
	 */
	turnEnd(room: Room, user: string): void {}
	/**
	 * 获得时触发
	 * @param room 房间
	 * @param user 使用者
	 */
	give(room: Room, user: string): void {}
	/**
	 * 被使用时触发
	 * @param room 房间
	 * @param user 使用者
	 * @param target 被使用者
	 */
	use(room: Room, user: string, target: string): void {}
	/**
	 * 被破坏时触发
	 * @param room 房间
	 * @param user 使用者
	 */
	destroy(room: Room, user: string): void {}

	// 电脑相关

	// 优先级
	priority(room: Room, user: string, target: string): number {
		return 50;
	}

	canToField(room: Room, user: string) {
		return false;
	}
	/**
	 * 前后端传输并不能传输class，所以我们需要将其转换为JSON
	 * @param room
	 * @returns
	 */
	toClient(room: Room, user: string) {
		const costMoney = this.costMoney(room, user);
		const costPoint = this.costPoint(room, user);
		const desc =
			(costMoney > 0 ? `(花费: ${costMoney}两)` : '') + this.desc(room, user);
		const title = this.title(room, user);
		const type = this.type(room, user);
		const background = this.background(room, user);
		const cardId = this.cardId;
		const target = this.target(room, user);
		return {
			target,
			cardId,
			costMoney,
			costPoint,
			desc,
			title,
			type,
			background,
		};
	}
}
